﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace PhanMemQuanLyCuaHangBanDienThoai
{
    public partial class Khach_Hang : Form
    {
        DataSet ds;
        OleDbDataAdapter daKhachHang;
        CurrencyManager cmKhachHang;
        public Khach_Hang()
        {
            InitializeComponent();
        }

        private void Khach_Hang_Load(object sender, EventArgs e)
        {
           
            ds = new DataSet();

            string strKetNoi = @"Provider=Microsoft.Jet.OleDB.4.0; Data Source=DTDD.mdb";
            string strSelect = @"SELECT * FROM KHACHHANG";
            daKhachHang = new OleDbDataAdapter(strSelect, strKetNoi);
            OleDbConnection con = new OleDbConnection(strKetNoi);
            //Giấy giới tính đưa vào Combobox
            cmbGioiTinh.DataSource = ds.Tables["tblKHACHHANG"];
            cmbGioiTinh.DisplayMember = "GioiTinh";
            cmbGioiTinh.SelectedIndex = -1;
            // Lay dong duoc chon tren Datagridview
            daKhachHang= new OleDbDataAdapter(strSelect, strKetNoi);
            daKhachHang.Fill(ds, "tblKHACHHANG");
            dgvKhachHang.DataSource = ds.Tables["tblKHACHHANG"];
            txtMaKH.DataBindings.Add("Text", ds.Tables["tblKHACHHANG"], "MaKH");
            txtTenKH.DataBindings.Add("Text", ds.Tables["tblKHACHHANG"], "TenKH");
            txtDiaChi.DataBindings.Add("Text", ds.Tables["tblKHACHHANG"], "DiaChi");
            txtSoDienThoai.DataBindings.Add("Text", ds.Tables["tblKHACHHANG"], "SDT");
            txtNamSinh.DataBindings.Add("Text", ds.Tables["tblKHACHHANG"], "NamSinh");
            cmbGioiTinh.DataBindings.Add("SelectedValue", ds.Tables["tblKHACHHANG"], "GioiTinh");
            cmKhachHang = (CurrencyManager)BindingContext[ds.Tables["tblKHACHHANG"]];
                
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            cmKhachHang.Position++;

        }


        private void btnFirst_Click(object sender, EventArgs e)
        {
            cmKhachHang.Position = 0;
        }

        private void btnLast_Click(object sender, EventArgs e)
        {
            cmKhachHang.Position = cmKhachHang.Count - 1;


        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {
            cmKhachHang.Position--;
        }

        private void dgvKhachHang_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
           
        }
    }
}
